<?php

namespace App\Modals;

use App\Models\Order;
use Illuminate\Contracts\Support\Renderable;

class OrderTend implements Renderable
{
    public function render($key = null)
    {
        $order = Order::query()->findOrFail($key);
        $read_info = $order->orderReadInfo()->groupBy('date', 'hour', 'min_area')
            ->selectRaw('sum(read_num_inc) as read_num_inc,date,hour,min_area')->get()->map(function ($item) {

                $item->time = $item->date . ' ' . $item->hour . ':' . $item->min_area * 5;
                return $item;

            });
        $expect_read_info = $order->curveOrderRecord()->get();

        return view('admin.order_tend', ['read_info' => $read_info]);

    }
}
